export const NAME = "DATAV";

/**
 * 组件位置数据类型
 */
export interface ILocation {
  x: number;
  y: number;
  width: number;
  height: number;
}

export enum ReuqestMethod {
  GET = "GET",
  POST = "POST",
  DELETE = "DELETE",
  PUT = "PUT",
}

export enum DataType {
  STATIC = "STATIC",
  DYNAMIC = "DYNAMIC",
}

export interface IRequest {
  dataType: DataType;
  url: string;
  method: ReuqestMethod;
  params: { [key: string]: string };
  data: { [key: string]: string };
  responseKey: string;
}

/**
 * 配置数据类型
 */
export interface IConfig {
  location: ILocation;
  data: object;
  option: object;
  request: IRequest;
  render: string;
  service: {
    after: string;
    service: string;
  };
  other: {
    group: string;
    icon: string;
    name: string;
  };
}

export interface ICanvasConfig {
  // 屏幕名称
  name: string;
  // 屏幕简介
  desc: string;
  // 屏幕宽度
  width: number;
  // 屏幕高度
  height: number;
  //全局变量
  globalVar: { name: string; type: string; value: "" }[];
  groupVar: { [key: string]: string };
  // 屏幕缩放比例
  scale: number;
  backgroundColor: string;
  // 屏幕背景图
  backgroundImage: string;
  // 请求前缀
  requestPrefix: string;
  // 图片前缀
  imagePrefix: string;
  // 是否适配
  adapt: true;
}

export interface IConfigStore {
  checkedList: string[];
  config: { [key: string]: IConfig };
  currentIndex: string;
  canvasConfig: ICanvasConfig;
}

export const DATAV_LAYOUT = "DATAV_LAYOUT";

export interface ILayout {
  showComponent: boolean;
  showLayer: boolean;
}
